<div class="fui-page order-list-page" ng-if="pagedata.op == 'main'">
	 <div class="jy2-headertopbg">
			<div class="fui-header" style="background:none">
				<div class="fui-header-left">
					<a class="back" style="color:#fff" href="javascript:" ng-click="goback()"></a>
				</div>
				<div class="title bold" style="font-size:1rem;color:#fff">我的水票</div>
			</div>
	 </div>
	<div class="fui-tab fui-tab-danger jy2-headertop" style="top:2.5rem;margin-top:0;min-height:3rem">
		<a ng-class="{'external active':pagedata.params.status == 10}" ng-click="pagedata.params.status = 10;tool.get_list('jy_weishopwater/sale.kabaoorder/getlist/',true)">全部</a>
		<a ng-class="{'external active':pagedata.params.status == 0}" href="javascript:" ng-click="pagedata.params.status = 0;tool.get_list('jy_weishopwater/sale.kabaoorder/getlist/',true)">待核销</a>
		<a ng-class="{'external active':pagedata.params.status == 3}" ng-click="pagedata.params.status=3;tool.get_list('jy_weishopwater/sale.kabaoorder/getlist/',true)">已核销完</a>
	</div>
	<div class='fui-content order-list' style="margin-top:0.7rem">
		<div ng-repeat="item in pagedata.list" style="background:#fff;margin-bottom:0.5rem">
		<div class="fui-list-group goods-list-group"> 
				 <div class="fui-list external" style="padding: 0.42rem 0.5rem"  ng-click="access_json('jy_weishopwater/sale.kabaoorderitem//id='+item.id)">
							<div class="fui-list-inner">
								<div class="subtitle"> 订单号: {{item.ordersn}}</div>
							</div>
							<div class="row-remark text-cancel" style="width: 4rem; font-size: 0.65rem;text-align: right;">{{item.statustitle}}</div>
							<div class="angle"></div>
				 </div> 
				<div class="fui-list-group-title bold">商品详情</div>
				<div ng-repeat="g in item.jiangs" ng-click="access_json('jy_weishopwater/sale.kabaoorderitem//id='+item.id)">
					<div class="fui-list">
						<div class="fui-list-media">
							<img ng-src="{{tomedia(g.goods.image)}}" class="round">
						</div>
						<div class="fui-list-inner">
							<div class="text goodstitle">{{g.goods.title}}</div>
							<div class="gray">{{g.goods.subtitle}}</div> 
						</div>
						<div class='fui-list-angle'>
						<span class='marketprice'>￥{{g.goods.price}} x{{g.total||1}}
						</div>
					</div>
				</div>
			</div>
                <div class="fui-list-group-title lineblock">
					<span style="color:#999;font-size:0.65rem"><i class="icon jinyunicon icon-shijian" style="color:#f60;font-size:0.60rem"></i> {{item.createtime}}</span>
                    <span class="status noremark" style="color:#999;font-size:0.65rem">(含 <span>{{item.jiangs.length}}</span> 个商品 价值: <span class="text-danger">￥{{item.kabao.price||item.payfee}}</span>) X {{item.total}}</span>
                </div>
				<div class="fui-list-group-title lineblock opblock">
					<span style="color:#999;font-size:0.65rem">剩余{{item.lastnum}}份可兑</span>
					<span class="status noremark">
						<div ng-show="item.status<=1 && item.lastnum>0" class="btn btn-sm btn-danger-o order-finish" href="javascript:;" ng-click="pagedata.post=item;pagedata.post.address=pagedata.address;pagedata.post.addressid=pagedata.address.id;pagedata.getgoods=true">一键订水</div>
						<div ng-show="item.orderid>0" class="btn btn-sm btn-danger-o order-finish" href="javascript:;" ng-click="access_json('jy_weishop/order.detail//id='+item.orderid)">查看订水情况</div>
					</span>
				</div>
        </div>
		<div class="content-empty" ng-show="!pagedata.list || pagedata.list.length == 0 ">
		  <i class="icon jinyunicon icon-cry" style="width: 6rem;margin-bottom: 0.5rem;"></i><br/><p style="color: #999;font-size: .75rem">您暂时没有记录！</p>
		</div>
	</div>
</div>
<div ng-if="pagedata.getgoods" class="popup">
	<div class="popup-body">
		<div class="popup-bottom" style="padding-bottom:2.5rem">
		<i class="closed icon icon-close" style="color:red;top:-2rem;" ng-click="pagedata.getgoods=false"></i>
		<div class="order-create-page modal-swiper-y" style='margin-top:5px;background:#fff;'>
			<div ng-if="pagedata.post.sendtypes" ng-include="sys_html('order/common/_peisong','','','jy_weishop')"></div>
			<div class="weui_cells">
			<div ng-if="pagedata.post.sendtype!=1" class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">联系人</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input ng-model="pagedata.post.username" class="weui_input" type="text" placeholder="请输入联系人">
					</div>
			</div>
			<div ng-if="pagedata.post.sendtype!=1" class="weui_cell">
					<div class="weui_cell_hd"><label class="weui_label">联系电话</label></div>
					<div class="weui_cell_bd weui_cell_primary">
						<input ng-model="pagedata.post.mobile" class="weui_input" type="text" placeholder="请输入电话">
					</div>
			</div>
			</div>
		</div>
		<div class='fui-navbar' style="padding:0.35rem 1rem">
			<div ng-if="!pagedata.pay_id" class="btn btn-danger btn-banf" style="margin:0;width:100%" ng-click="pagedata.togget()">提交</div>
			<div ng-if="pagedata.pay_id" class="btn btn-danger btn-banf disabled" style="width:100%" ng-click="pagedata.pay()">查看订单</div>
		</div>
		</div>
	</div>
</div>
<div ng-if="pagedata.showtuikuan" class="popup">
	<div class="popup-body">
		<div class="popup-bottom" style="padding-bottom:2.5rem;padding-top:2rem">
		<i class="closed icon icon-close" style="color:red;top:0.3rem" ng-click="pagedata.showtuikuan=false"></i>
		<div class="fui-cellone">
			<div class="fui-cellone-label" style="width:auto">
				<span>当前剩余礼包数：</span>
			</div>
			<div class="fui-cellone-info">{{pagedata.nowitem.lslognum}}个</div>
		</div>
		<div class="weui_btn_area">
			<a class="weui_btn weui_btn_primary" style="padding:0.5rem;border-radius:2rem" href="javascript:" ng-click="post({},'jy_weishopwater/sale.kabaoorder/tuikuan/id='+pagedata.nowitem.id)">
				<div class="bold" style="line-height:1.5">￥{{pagedata.nowitem.lsprice||'0.00'}}</div>
				<div style="line-height:1.5">确定退款</div>
			</a>
		</div>
		</div>
	</div>
</div>
<div ng-include="sys_html('common/pluginnav',true)"></div>
<script>
scope.pagedata.togget=function(){
	scope.confirm({
		'message':'确定要扣除一张水票，定一桶水吗？',
		'success':function(){
			scope.post_json('jy_weishopwater/sale.kabaoorder/getgoods/',scope.pagedata.post,function(result){
				if(scope.pagedata.pluginset.peisongfee>0){
					scope.tool.pay(result.pay_id,function(res){
						if(res.type=='success'){
							scope.message('支付成功！','success','/orderlist/');
						}else{
							scope.message('支付失败！','success','/orderlist/');
						}
					},'','','/orderlist/');
					scope.pagedata.pay_id=result.pay_id;
					scope.$evalAsync();
				}else{
					scope.message('提交成功！','success','/orderlist/');
				}
			});
		},
		'fail':function(){}
	});
}
scope.pagedata.pay=function(){
	scope.post_json('jy_weishopwater/sale.kabaoorder/pay/id='+scope.pagedata.post.id,{},function(pay_id){
		scope.tool.pay(pay_id,function(res){
				if(res.type=='success'){
					scope.message('支付成功！','success','/orderlist/');
				}else{
					scope.message('支付失败！','success','/orderlist/');
				}
		},'','','/orderlist/');
	});
}
scope.tool.get_list('jy_weishopwater/sale.kabaoorder/getlist/',true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_weishopwater/sale.kabaoorder/getlist/');
}
</script>